package trafficmanager

import (
	"dev.ixmxm.top/rms/model"
)

type mapInfo struct {
	ProjectId   string
	TrafficName string
}

func (tm *TrafficManager) GetNode(mapName string, site string) model.Node {
	return tm.planers[mapName].GetNode(site)
}
func (tm *TrafficManager) GetNode1(mapName string, site string) *model.Node {
	return tm.planers[mapName].GetNode1(site)
}

func (tm *TrafficManager) GetMapFF(mapName string) mapInfo {
	res, find := tm.mapNameMapping[mapName]
	if !find {
		panic("map name mapping not find")
	}
	return res
}

//检测地图名是否存在
func (tm *TrafficManager) MapNameExists(mapName string) bool {
	_, find := tm.mapNameMapping[mapName]
	return find
}

func (tm *TrafficManager) GetMapName(projectId, trafficName string) string {
	for name, ff := range tm.mapNameMapping {
		if ff.ProjectId == projectId && ff.TrafficName == trafficName {
			return name
		}
	}
	return ""
	// panic("map name mapping not find")
}

//获取所有的地图名
func (tm *TrafficManager) GetAllMapNames() []string {
	keys := make([]string, 0, len(tm.mapNameMapping))
	for k := range tm.mapNameMapping {
		keys = append(keys, k)
	}
	return keys
}
